<!DOCTYPE html>
<html lang="ch">
<!--开启session-->
<?php session_start(); ?>
<head>
    <meta charset="utf-8">
    <title>多门店管理系统</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/bootstrap-table.min.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/bootstrap-table.min.js"></script>
    <script src="js/bootstrap-table-zh-CN.min.js"></script>

    <!--    js获取日期-->
    <script>
        $(function time() {
            var now = new Date();
            var year = now.getFullYear();
            var month = now.getMonth();
            var date = now.getDate();
            //获取相应ID
            document.getElementById("timer").innerHTML = "时间：" + year + "年" + (month + 1) + "月" + date + "日";
        })
    </script>
    <!--    table显示-->
    <script>
        //加载表格
        function loadTable() {
            $('#mytab').bootstrapTable('destroy');
            $('#mytab').bootstrapTable({
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",//不变
                method: "post",//不变
                dataType: "json",//不变
                url: "4.2ClothsSale.php",//改成目标php
                // data:[{
                //     'id':'233',
                //     'name':'lisi'
                // },{'id':'...','name':'...'}],
                sortOrder: "asc",                   //排序方式
                showExport: true,                     //是否显示导出为excel的按钮
                exportDataType: "basic",              //basic', 'all', 'selected'
                striped: true, //是否显示行间隔色
                pageNumber: 1, //初始化加载第一页
                pagination: true,//是否分页
                sidePagination: 'client',//server:服务器端分页|client：前端分页
                pageSize: 5,//单页记录数
                pageList: [5, 10, 20, 30, 50],//可选择单页记录数
                showRefresh: false,//刷新按钮
                queryParams: function getParams(params) {//上传服务器的参数
                    params.goodid = $("#good_id").val();
                    params.style = $("#sty_le").val();
                    params.color = $("#col_or").val();
                    params.size = $("#si_ze").val();
                    params.number = $("#num_ber").val();
                    return params;
                },
                columns: [
                    {
                        title: "序号",
                        field: "index",
                        align: 'center',
                        formatter: function (value, row, index) {
                            return index + 1;
                        }
                    },
                    {
                        title: "商品编号",
                        field: "good_id",
                        align: 'center', //center居中，left左对齐，right右对齐
                        sortable: true,
                    },
                    {
                        title: '数量',
                        field: 'num',
                        align: 'center',
                        // sortable : true
                    },
                    {
                        title: '款式',
                        field: 'style',
                        align: 'center',
                        // sortable : true
                    },
                    {
                        title: '颜色',
                        field: 'color',
                        align: 'center',
                        // sortable : true
                    },
                    {
                        title: '尺码',
                        field: 'size',
                        align: 'center',
                        // sortable : true
                    },
                    {
                        title: '单价',
                        field: 'single_price',
                        align: 'center',
                        // sortable : true
                    },
                    {
                        title: '折扣',
                        field: 'discount',
                        align: 'center',
                        // sortable : true
                    },
                    {
                        title: '所在店',
                        field: 'shop_id',
                        align: 'center',
                    },
                    {
                        title: '操作',
                        field: 'option',
                        align: 'center',
                        events: operatEvents,
                        formatter: operatFrom,
                    },

                ]
            });
        }

        //加载按钮，出售或是调货
        function operatFrom(value, row, index) {
            //return "<a href='javascript:;' οnclick='editRow(event)'>编辑</a>&nbsp;&nbsp;<a href='javascript:;' οnclick='deleteRow(event)'>删除</a>";
            var sid = "<?php echo $_SESSION['user']['shop_id']; ?>";
            if (row.shop_id == sid) {
                var sell_button = '<button type="button" class="btn btn-primary btn-sm" id="sellout" style="margin-right:15px;">出售</button>';
            } else {
                var sell_button = '<button type="button" class="btn btn-primary btn-sm" id="transfer" style="margin-right:15px;">调货</button>';
            }
            return [
                sell_button]
                .join('');
        }

        //规定按钮的事件
        window.operatEvents = {
            "click #sellout": function (e, value, row, index) {
                $.ajax({
                    type: "POST",
                    url: "4.3.1.1ClothSaleComfirm.php",
                    dataType: "json",
                    data: {
                        goodid: row.good_id,
                        number: $('#num_ber').val(),
                        price: row.single_price,
                        discount: row.discount,
                    },
                    success: function (responseText) {
                        alert(responseText.status); //和后台商量keyname
                        history.go(0);
                    }
                });
            },
            "click #transfer": function (e, value, row, index) {
                $.ajax({
                    type: "POST",
                    url: "4.3.1.2ClothSaleTransfer.php",
                    dataType: "json",
                    data: {
                        goodid: row.good_id,
                        number: $('#num_ber').val(),
                        ans_shop: row.shop_id,
                    },
                    success: function (responseText) {
                        alert(responseText.status); //和后台商量keyname
                        history.go(0);
                    }
                });
            }
        }
    </script>
</head>

<body style="background: #eeeeee">
<div class="jumbotron text-center" style="margin-bottom:0; ">
    <h1>多门店管理系统</h1>
    <div id="timer" style="float: right; font-size: 20px;"></div>
</div>

<nav class="navbar navbar-inverse">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
        </div>
        <div class="collapse navbar-collapse" id="myNavbar">
            <ul class="nav navbar-nav">
                <li><a href="main.php" style="font-size: 20px;">我的信息</a></li>
                <li><a href="search.php" style="font-size: 20px;">库存查询</a></li>
                <li><a href="purchase.php" style="font-size: 20px;">进货</a></li>
                <li><a href="sell.php" style="font-size: 20px;">售货</a></li>
                <li><a href="less.php" style="font-size: 20px;">缺货情况</a></li>
                <li><a href="transfer1.php" style="font-size: 20px;">发出的申请</a></li>
                <li><a href="transfer2.php" style="font-size: 20px;">收到的申请</a></li>
                <li><a href="statistic1.php" style="font-size: 20px;">本店销售排名</a></li>
                <li><a href="statistic2.php" style="font-size: 20px;">销售记录</a></li>
            </ul>
        </div>
    </div>
</nav>


<div class="container">

    <div class="row">
        <div class="col-md-8">
            <h4 class="page-head-line">请根据需要，输入查询数据</h4>
            <div class="Compose-Message">
                <div class="panel panel-success">
                    <div class="panel-heading">
                        查询
                    </div>
                    <div class="panel-body">

                        <label>商品编号 : </label>
                        <input type="text" id="good_id" class="form-control"/>
                        <label>款式 : </label>
                        <input type="text" id="sty_le" class="form-control"/>
                        <label>颜色 : </label>
                        <input type="text" id="col_or" class="form-control"/>
                        <label>尺码 : </label>
                        <input type="text" id="si_ze" class="form-control"/>
                        <label>售出数量 : </label>
                        <input type="text" id="num_ber" class="form-control"/>
                        <hr/>
                        <button class="btn btn-warning" onclick="history.go(0);"> 重置</button>&nbsp;
                        <button class="btn btn-success" onclick="loadTable()"> 查询</button>
                    </div>
                    <div class="panel-footer text-muted">
                        <strong>Note : </strong>Please note that we track all messages so don't send any spams.
                    </div>
                </div>
                <table class="table table-striped" id="mytab"></table>
            </div>
        </div>
        <div class="col-md-4">
            <div style="float: right;">
                <div id="all">
                    <div class="content" style="text-align: center; border: 1px solid #000000;">
                        <img width="200px" height="200px" src="img/xyq0411.jpg"/>
                        <p>姓名：<?php echo $_SESSION['user']['name']; ?></p>
                        <p>职位：<?php echo $_SESSION['user']['type']; ?></p>
                        <p>所在店：<?php echo $_SESSION['user']['shop_id']; ?></p>
                        <p>用户名：<?php echo $_SESSION['user']['id']; ?></p>
                        <p>
                            <button type="button" onclick="window.location.href='0.2LogOut.php'"
                                    class="btn btn-primary btn-lg ">注销
                            </button>
                        </p>
                    </div>
                </div>
            </div>
            <div style="float: right; margin-top: 20px;">
                <div id="xiaoxun">
                    <div class="content" style="text-align: center; border: 3px solid #B21F2D;">
                        <p style="font-size: 46px; color: #B21F2D;">明德 厚学</p>
                        <p style="font-size: 46px; color: #B21F2D;">求是 创新</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


</body>
</html>